extends ../layout/base

include ../mixins/columns

block css
	if list.fieldTypes.code
		link(rel='stylesheet', href='/keystone/js/lib/codemirror/codemirror.css')

block js
	script.
		Keystone.list = !{JSON.stringify(list.getOptions())};
		Keystone.wysiwyg = { options: !{JSON.stringify(wysiwygOptions)} };
		Keystone.itemId = '!{item.id}';
	script(src='/keystone/js/packages.js')
	script(src='/keystone/js/fields.js')
	script(src='/keystone/js/item.js')

block js_codemirror
	if list.fieldTypes.code
		script(src="/keystone/js/lib/codemirror/codemirror-compressed.js")
		
block content
	// Attach point for new React View
	div#item-view
	
	if showRelationships
		h2.relationship-heading.form-heading Relationships
			each rel in relationships
				if rel.items.results.length
					h3.form-heading.relationship-heading: a(href='/keystone/' + rel.list.path)= (rel.label) ? rel.label : rel.list.label
					if rel.note
						.field-note= rel.note
					- var firstColspan = 1
					table(cellpadding=0, cellspacing=0, class=rel.sortable ? 'sortable' : false, data-list-path=rel.list.path).table.table-striped.items-list.relationships-list
						if rel.sortable
							- firstColspan++;
							col(width=26)
						each col in rel.columns
							col(width=col.width)
						thead
							tr
								each col, i in rel.columns
									th(colspan=i == 0 && firstColspan > 1 ? firstColspan : false)= col.label
						tbody
							each item in rel.items.results
								tr(id=item.id)
									if rel.sortable
										td.control: a(href=js).control-sort
									each col, i in rel.columns
										td
											+column(rel.list, col, item)


